<?php

namespace register\view;

class RegisterView {

	private static $REGISTER = "LoginView::Register";
	private static $NEWUSERNAME = "LoginView::NewUserName";
	private static $NEWPASSWORD = "LoginView::NewPassWord";
	private static $REPEATNEWPASSWORD = "LoginView::RepeatNewPassWord";
	private static $BACKBUTTON = "LoginView::BackButton";
	/**
	 * Used to pass messages to client
	 *
	 * @var string
	 */
	private $message = "";

	public function registerNewUserHTML() {

		$registerHTML = "
		
		<form action='?' method='post'>
			<fieldset>
			<br>
			$this->message
			<br>
				<legend>Registrera ny användare</legend>
				<label for='NewUserName'>Användarnamn :</label>
				<input type='text' size='20' name='" . self::$NEWUSERNAME . "' id='NewUserName' value='" . $_POST[self::$NEWUSERNAME] . "'/>
				<label for='NewPassWord'>Lösenord :</label>
				<input type='text' size='20' name='" . self::$NEWPASSWORD . "' id='NewPassWord'/>
				<label for='repeatNewPassWord'> Upprepa lösenord :</label>
				<input type='text' size='20' name='" . self::$REPEATNEWPASSWORD . "' id='NewPassWord'/>
				<input type='submit' name='" . self::$REGISTER . "'  value='Registrera' />
			</fieldset>
		</form>
		<form>
			<input type='submit' name='" . self::$BACKBUTTON . "'  value='Tillbaka' />
		</form>
		";

		return $registerHTML;
	}

	public function registerButtonPressed() {
		return isset($_POST[self::$REGISTER]);

	}

	public function getFormInputUser() {

		return $_POST[self::$NEWUSERNAME];

	}

	public function getFormInputPassWord() {

		return $_POST[self::$NEWPASSWORD];

	}

	public function setErrorMessage($message) {

		$this -> message = $message;

	}

	public function backButtonPressed() {
		
		return isset($_POST[self::$BACKBUTTON]);

	}

}
